package com.java1412.common.utils;

import java.util.HashMap;

/**
 * 返回给前端的结果工具类
 *
 * @author java1412
 * @since 2025-05-16 13:47
 */
public class R extends HashMap<String, Object> {

    /**
     * 不含数据的状态对象
     *
     * @param responseEnum
     * @return
     */
    public static R r(ResponseEnum responseEnum) {
        R r = new R();
        r.put("code", responseEnum.getCode());
        r.put("msg", responseEnum.getMessage());
        return r;
    }

    /**
     * 含有数据的状态对象
     *
     * @param responseEnum
     * @param data
     * @return
     */
    public static R r(ResponseEnum responseEnum, Object data) {
        R r = R.r(responseEnum);
        r.put("data", data);
        return r;
    }
}
